﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EFong.ServicesInterface;
using EFong.BL;

namespace EFong.Services
{
    public class BusinessService : IBusinessService, IService
    {
        #region IBusinessService 成员

        public Contract.ServiceResult<string> NewFlightOrder(Contract.FlightOrder flightOrder)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<string>(businessBL.NewFlightOrder(flightOrder));
            }
            catch (BusinessException be) { return this.Fail<string>(be); }
            catch (Exception e) { return this.Fail<string>(e); }
        }

        public Contract.ServiceResult<string> UpdateFlightOrder(Contract.FlightOrder flightOrder)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<string>(businessBL.UpdateFlightOrder(flightOrder));
            }
            catch (BusinessException be) { return this.Fail<string>(be); }
            catch (Exception e) { return this.Fail<string>(e); }
        }

        public Contract.ServiceResult VoidFlightOrder(Contract.FlightOrder flightOrder, string cause)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                businessBL.VoidFlightOrder(flightOrder, cause);
                return this.Return();
            }
            catch (BusinessException be) { return this.Fail(be); }
            catch (Exception e) { return this.Fail(e); }
        }

        public Contract.ServiceResult KeepFlightOrderDetail(Contract.FlightOrderDatail flightOrderDatail)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                businessBL.KeepFlightOrderDetail(flightOrderDatail);
                return this.Return();
            }
            catch (BusinessException be) { return this.Fail(be); }
            catch (Exception e) { return this.Fail(e); }
        }

        public Contract.ServiceResult<string> ChangeFlightOrder(Contract.FlightChange flightChange, Contract.FlightOrderDatail flightOrderDatail, decimal profit)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<string>(businessBL.ChangeFlightOrder(flightChange, flightOrderDatail, profit));
            }
            catch (BusinessException be) { return this.Fail<string>(be); }
            catch (Exception e) { return this.Fail<string>(e); }
        }

        public Contract.ServiceResult<string> ReturnFlightOrder(Contract.FlightReturn flightReturn, Contract.FlightOrderDatail flightOrderDatail, decimal profit)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<string>(businessBL.ReturnFlightOrder(flightReturn, flightOrderDatail, profit));
            }
            catch (BusinessException be) { return this.Fail<string>(be); }
            catch (Exception e)  { return this.Fail<string>(e); }
        }

        public Contract.ServiceResult<string> NewTrainTicketOrder(Contract.TrainTicketOrder trainTicketOrder)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<string>(businessBL.NewTrainTicketOrder(trainTicketOrder));
            }
            catch (BusinessException be) { return this.Fail<string>(be); }
            catch (Exception e) { return this.Fail<string>(e); }
        }

        public Contract.ServiceResult<string> UpdateTrainTicketOrder(Contract.TrainTicketOrder trainTicketOrder)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<string>(businessBL.UpdateTrainTicketOrder(trainTicketOrder));
            }
            catch (BusinessException be) { return this.Fail<string>(be); }
            catch (Exception e) { return this.Fail<string>(e); }
        }

        public Contract.ServiceResult VoidTrainTicketOrder(Contract.TrainTicketOrder trainTicketOrder, string cause)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                businessBL.VoidTrainTicketOrder(trainTicketOrder, cause);
                return this.Return();
            }
            catch (BusinessException be) { return this.Fail(be); }
            catch (Exception e) { return this.Fail(e); }
        }

        public Contract.ServiceResult<string> ReturnTrainTicketOrder(Contract.TrainTicketReturn trainTicketReturn, Contract.TrainTicketOrderDetail trainTicketOrderDetail, decimal profit)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<string>(businessBL.ReturnTrainTicketOrder(trainTicketReturn, trainTicketOrderDetail, profit));
            }
            catch (BusinessException be) { return this.Fail<string>(be); }
            catch (Exception e) { return this.Fail<string>(e); }
        }

        public Contract.ServiceResult<string> NewHotelBooking(Contract.HotelBooking hotelBooking)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<string>(businessBL.NewHotelBooking(hotelBooking));
            }
            catch (BusinessException be) { return this.Fail<string>(be); }
            catch (Exception e) { return this.Fail<string>(e); }
        }

        public Contract.ServiceResult<string> UpdateHotelBooking(Contract.HotelBooking hotelBooking)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<string>(businessBL.UpdateHotelBooking(hotelBooking));
            }
            catch (BusinessException be) { return this.Fail<string>(be); }
            catch (Exception e) { return this.Fail<string>(e); }
        }

        public Contract.ServiceResult VoidHotelBooking(Contract.HotelBooking hotelBooking, string cause)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                businessBL.VoidHotelBooking(hotelBooking, cause);
                return this.Return();
            }
            catch (BusinessException be) { return this.Fail(be); }
            catch (Exception e) { return this.Fail(e); }
        }

        public Contract.ServiceResult<string> NewOtherBusiness(Contract.OtherBusiness otherBusiness)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<string>(businessBL.NewOtherBusiness(otherBusiness));
            }
            catch (BusinessException be) { return this.Fail<string>(be); }
            catch (Exception e) { return this.Fail<string>(e); }
        }

        public Contract.ServiceResult<string> UpdateOtherBusiness(Contract.OtherBusiness otherBusiness)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<string>(businessBL.UpdateOtherBusiness(otherBusiness));
            }
            catch (BusinessException be) { return this.Fail<string>(be); }
            catch (Exception e) { return this.Fail<string>(e); }
        }

        public Contract.ServiceResult VoidOtherBusiness(Contract.OtherBusiness otherBusiness, string cause)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                businessBL.VoidOtherBusiness(otherBusiness, cause);
                return this.Return();
            }
            catch (BusinessException be) { return this.Fail(be); }
            catch (Exception e) { return this.Fail(e); }
        }

        public Contract.ServiceResult IntergralExchange(Contract.IntergralExchange intergralExchange)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                businessBL.IntergralExchange(intergralExchange);
                return this.Return();
            }
            catch (BusinessException be) { return this.Fail(be); }
            catch (Exception e) { return this.Fail(e); }
        }

        public Contract.ServiceResult<List<Contract.IntergralExchange>> GetIntergralExchangeByMonth(DateTime month) 
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.IntergralExchange>>(businessBL.GetIntergralExchangeByMonth(month));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.IntergralExchange>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.IntergralExchange>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RFlightOrder>> GetAllFlightOrder()
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RFlightOrder>>(businessBL.GetAllFlightOrder());
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RFlightOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RFlightOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RFlightOrder>> GetFlightOrderByRef(string _ref)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RFlightOrder>>(businessBL.GetFlightOrderByRef(_ref));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RFlightOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RFlightOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RFlightOrder>> GetFlightOrderByCustomer(Contract.RCustomer customer)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RFlightOrder>>(businessBL.GetFlightOrderByCustomer(customer));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RFlightOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RFlightOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RFlightOrder>> GetFlightOrderByOrderDate(DateTime startDate, DateTime endDate)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RFlightOrder>>(businessBL.GetFlightOrderByOrderDate(startDate, endDate));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RFlightOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RFlightOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RFlightOrder>> GetFlightOrderByVendor(Contract.RVendor vendor)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RFlightOrder>>(businessBL.GetFlightOrderByVendor(vendor));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RFlightOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RFlightOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RFlightOrder>> GetFlightOrderByPassenger(string passenger)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RFlightOrder>>(businessBL.GetFlightOrderByPassenger(passenger));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RFlightOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RFlightOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RFlightOrder>> GetFlightOrderByTicketNo(string ticketNo)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RFlightOrder>>(businessBL.GetFlightOrderByTicketNo(ticketNo));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RFlightOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RFlightOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RFlightOrder>> GetFlightOrderByAirwaysOrderNo(string airwaysOrderNo)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RFlightOrder>>(businessBL.GetFlightOrderByAirwaysOrderNo(airwaysOrderNo));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RFlightOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RFlightOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RFlightOrder>> GetFlightOrderByWayType(string wayType)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RFlightOrder>>(businessBL.GetFlightOrderByWayType(wayType));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RFlightOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RFlightOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RFlightOrder>> GetFlightOrderByJourneyOrder(string journeyOrder) 
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RFlightOrder>>(businessBL.GetFlightOrderByJourneyOrder(journeyOrder));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RFlightOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RFlightOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RTrainTicketOrder>> GetAllTrainTicketOrder()
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RTrainTicketOrder>>(businessBL.GetAllTrainTicketOrder());
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RTrainTicketOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RTrainTicketOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RTrainTicketOrder>> GetTrainTicketOrderByRef(string _ref)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RTrainTicketOrder>>(businessBL.GetTrainTicketOrderByRef(_ref));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RTrainTicketOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RTrainTicketOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RTrainTicketOrder>> GetTrainTicketOrderByCustomer(Contract.RCustomer customer)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RTrainTicketOrder>>(businessBL.GetTrainTicketOrderByCustomer(customer));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RTrainTicketOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RTrainTicketOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RTrainTicketOrder>> GetTrainTicketOrderByOrderDate(DateTime startDate, DateTime endDate)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RTrainTicketOrder>>(businessBL.GetTrainTicketOrderByOrderDate(startDate, endDate));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RTrainTicketOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RTrainTicketOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RTrainTicketOrder>> GetTrainTicketOrderByVendor(Contract.RVendor vendor)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RTrainTicketOrder>>(businessBL.GetTrainTicketOrderByVendor(vendor));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RTrainTicketOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RTrainTicketOrder>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RHotelBooking>> GetAllHotelBooking()
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RHotelBooking>>(businessBL.GetAllHotelBooking());
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RHotelBooking>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RHotelBooking>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RHotelBooking>> GetHotelBookingByRef(string _ref)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RHotelBooking>>(businessBL.GetHotelBookingByRef(_ref));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RHotelBooking>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RHotelBooking>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RHotelBooking>> GetHotelBookingByGuestName(string guestName)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RHotelBooking>>(businessBL.GetHotelBookingByGuestName(guestName));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RHotelBooking>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RHotelBooking>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RHotelBooking>> GetHotelBookingByCustomer(Contract.RCustomer customer)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RHotelBooking>>(businessBL.GetHotelBookingByCustomer(customer));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RHotelBooking>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RHotelBooking>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RHotelBooking>> GetHotelBookingByOrderDate(DateTime startDate, DateTime endDate)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RHotelBooking>>(businessBL.GetHotelBookingByOrderDate(startDate, endDate));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RHotelBooking>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RHotelBooking>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RHotelBooking>> GetHotelBookingByVendor(Contract.RVendor vendor)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RHotelBooking>>(businessBL.GetHotelBookingByVendor(vendor));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RHotelBooking>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RHotelBooking>>(e); }
        }

        public Contract.ServiceResult<List<Contract.ROtherBusiness>> GetAllOtherBusiness()
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.ROtherBusiness>>(businessBL.GetAllOtherBusiness());
            }
            catch (BusinessException be) { return this.Fail<List<Contract.ROtherBusiness>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.ROtherBusiness>>(e); }
        }

        public Contract.ServiceResult<List<Contract.ROtherBusiness>> GetOtherBusinessByRef(string _ref)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.ROtherBusiness>>(businessBL.GetOtherBusinessByRef(_ref));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.ROtherBusiness>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.ROtherBusiness>>(e); }
        }

        public Contract.ServiceResult<List<Contract.ROtherBusiness>> GetOtherBusinessByCustomer(Contract.RCustomer customer)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.ROtherBusiness>>(businessBL.GetOtherBusinessByCustomer(customer));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.ROtherBusiness>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.ROtherBusiness>>(e); }
        }

        public Contract.ServiceResult<List<Contract.ROtherBusiness>> GetOtherBusinessByOrderDate(DateTime startDate, DateTime endDate)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.ROtherBusiness>>(businessBL.GetOtherBusinessByOrderDate(startDate, endDate));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.ROtherBusiness>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.ROtherBusiness>>(e); }
        }

        public Contract.ServiceResult<List<Contract.ROtherBusiness>> GetOtherBusinessByVendor(Contract.RVendor vendor)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.ROtherBusiness>>(businessBL.GetOtherBusinessByVendor(vendor));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.ROtherBusiness>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.ROtherBusiness>>(e); }
        }

        public Contract.ServiceResult<List<Contract.ROtherBusiness>> GetOtherBusinessByProject(Contract.Project project, Contract.SubProject subProject, string content)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.ROtherBusiness>>(businessBL.GetOtherBusinessByProject(project, subProject, content));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.ROtherBusiness>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.ROtherBusiness>>(e); }
        }

        public Contract.ServiceResult<Contract.FlightOrder> GetFlightOrderByID(Guid id)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<Contract.FlightOrder>(businessBL.GetFlightOrderByID(id));
            }
            catch (BusinessException be) { return this.Fail<Contract.FlightOrder>(be); }
            catch (Exception e) { return this.Fail<Contract.FlightOrder>(e); }
        }



        public Contract.ServiceResult<Contract.TrainTicketOrder> GetTrainTicketOrderByID(Guid id)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<Contract.TrainTicketOrder>(businessBL.GetTrainTicketOrderByID(id));
            }
            catch (BusinessException be) { return this.Fail<Contract.TrainTicketOrder>(be); }
            catch (Exception e) { return this.Fail<Contract.TrainTicketOrder>(e); }
        }

        public Contract.ServiceResult<Contract.HotelBooking> GetHotelBookingByID(Guid id)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<Contract.HotelBooking>(businessBL.GetHotelBookingByID(id));
            }
            catch (BusinessException be) { return this.Fail<Contract.HotelBooking>(be); }
            catch (Exception e) { return this.Fail<Contract.HotelBooking>(e); }
        }

        public Contract.ServiceResult<Contract.OtherBusiness> GetOtherBusinessByID(Guid id)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<Contract.OtherBusiness>(businessBL.GetOtherBusinessByID(id));
            }
            catch (BusinessException be) { return this.Fail<Contract.OtherBusiness>(be); }
            catch (Exception e) { return this.Fail<Contract.OtherBusiness>(e); }
        }

        public Contract.ServiceResult<List<Contract.IntergralExchange>> SearchIntergralExchange(DateTime month) 
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.IntergralExchange>>(businessBL.SearchIntergralExchange(month));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.IntergralExchange>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.IntergralExchange>>(e); }
        }

        public Contract.ServiceResult<List<Contract.RFlightOrder>> GetFlightOrderByIsKeep(bool isKeep)
        {
            try
            {
                BusinessBL businessBL = new BusinessBL();
                return this.Return<List<Contract.RFlightOrder>>(businessBL.GetFlightOrderByIsKeep(isKeep));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.RFlightOrder>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.RFlightOrder>>(e); }
        }

        #endregion
    }
}
